package guet.dream.question.servlet;

import guet.dream.question.Question;
import guet.dream.question.QuestionDaoImpl;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class QShowServlet
 */
public class QShowServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	/**
	 * @see HttpServlet#
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
		
		String id = request.getParameter("id");
		QuestionDaoImpl questionDao = new QuestionDaoImpl();
		Question question = questionDao.findById(Integer.valueOf(id));
		request.setAttribute("question", question);
		
        RequestDispatcher view = request.getRequestDispatcher("/question/show.jsp");
        view.forward(request, response);
	}

}
